<%@ page contentType="text/html; charset=utf-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="f" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="s" uri="http://stripes.sourceforge.net/stripes.tld" %>

<f:message var="headline" key="houses.all"/>
<s:layout-render name="/content.jsp" nadpis="${headline}">
    <s:layout-component name="telo">
        <s:useActionBean beanclass="cz.muni.fi.hauntedhousesweb.web.HousesActionBean" var="actionBean"/>
        <table class="zakladni">
            <tr>
                <th><f:message key="houses.id" /></th>
                <th><f:message key="houses.name" /></th>
                <th><f:message key="houses.address" /></th>
                <th><f:message key="houses.history" /></th>
            </tr>
            <c:forEach items="${actionBean.houses}" var="house">
                <tr>
                    <td>${house.id}</td>
                    <td><c:out value="${house.name}"/></td>
                    <td><c:out value="${house.address}"/></td>
                    <td><c:out value="${house.history}"/></td>
                    <c:if test="${pageContext.request.isUserInRole('ROLE_ADMIN')}" >
                    <td><s:link beanclass="cz.muni.fi.hauntedhousesweb.web.HousesActionBean" event="delete"><s:param name="house.id" value="${house.id}"/><f:message key="global.delete" /></s:link> </td>
                    <td><s:link beanclass="cz.muni.fi.hauntedhousesweb.web.HousesActionBean" event="edit"><s:param name="house.id" value="${house.id}"/><f:message key="global.edit" /></s:link> </td>
                    </c:if>
                </tr>
            </c:forEach>
        </table>
        
        <c:if test="${pageContext.request.isUserInRole('ROLE_ADMIN')}" >
        <s:form beanclass="cz.muni.fi.hauntedhousesweb.web.HousesActionBean">
            <fieldset><legend><f:message key="houses.addNewHouse" /></legend>
                <%@include file="formHouses.jsp"%>
            <s:submit name="add" class="button"><f:message key="ghosts.add" /></s:submit>
            </fieldset>
        </s:form>
        </c:if>
    </s:layout-component>
</s:layout-render>
